{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3 4]\n",
      "1\n",
      "(4,)\n",
      "4\n",
      "[[1 2]\n",
      " [3 4]\n",
      " [5 6]]\n",
      "2\n",
      "(3, 2)\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "# 维度参数\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "# 一维数组\n",
    "A = np.array([1, 2, 3, 4])\n",
    "print(A)\n",
    "print(np.ndim(A))   # 数组维数\n",
    "print(A.shape)      # 数组形状\n",
    "print(A.shape[0])\n",
    "\n",
    "# 二维数组\n",
    "B = np.array([[1, 2], [3, 4], [5, 6]])\n",
    "print(np.ndim(B))\n",
    "print(B.shape)\n",
    "print(B.shape[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2, 2)\n",
      "(2, 2)\n",
      "[[19 22]\n",
      " [43 50]]\n",
      "(2, 3)\n",
      "(3, 2)\n",
      "[[22 28]\n",
      " [49 64]]\n"
     ]
    }
   ],
   "source": [
    "# 矩阵乘法\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "# 2x2-2x2\n",
    "A = np.array([[1, 2], [3, 4]])\n",
    "print(A.shape)\n",
    "B = np.array([[5, 6], [7, 8]])\n",
    "print(B.shape)\n",
    "print(np.dot(A, B))\n",
    "\n",
    "# 2x3-3x2\n",
    "A = np.array([[1, 2, 3], [4, 5, 6]])\n",
    "print(A.shape)\n",
    "B = np.array([[1, 2], [3, 4], [5, 6]])\n",
    "print(B.shape)\n",
    "print(np.dot(A, B))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2]\n",
      "(2,)\n",
      "[[1 3 5]\n",
      " [2 4 6]]\n",
      "(2, 3)\n",
      "[ 5 11 17]\n"
     ]
    }
   ],
   "source": [
    "# 神经网络内积\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "X = np.array([1, 2])\n",
    "print(X)\n",
    "print(X.shape)\n",
    "W = np.array([[1, 3, 5], [2, 4, 6]])\n",
    "print(W)\n",
    "print(W.shape)\n",
    "Y = np.dot(X, W)\n",
    "print(Y)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}